﻿// Type: trx2html.Parser.TestClassRun
// Assembly: RidoTasks, Version=0.7.3.1523, Culture=neutral, PublicKeyToken=null
// Assembly location: C:\Users\jigar\Desktop\Vinay\trx2html_0.7\0.7.3\RidoTasks.dll

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace trx2html
{
  internal class TestClassRun : I3ValueBar
  {
    private string fullname;
    public IEnumerable<TestMethodRun> TestMethods;

    public string Name
    {
      get
      {
        if (this.fullname.IndexOf(',') > 0)
          return this.fullname.Substring(0, this.fullname.IndexOf(','));
        else
          return this.fullname;
      }
    }

    public AssemblyName AssemblyName
    {
      get
      {
        int num = this.fullname.IndexOf(',');
        return new AssemblyName(this.fullname.Substring(num + 1, this.fullname.Length - num - 1));
      }
    }

    public double Percent
    {
      get
      {
        Enumerable.Count<TestMethodRun>(this.TestMethods);
        return Math.Round((1.0 - this.Failed / ((double) this.Total - this.Ignored)) * 100.0, 2);
      }
    }

    public double Success
    {
      get
      {
        return (double) Enumerable.Count<TestMethodRun>(Enumerable.Where<TestMethodRun>(this.TestMethods, (Func<TestMethodRun, bool>) (m => m.Status == "Passed")));
      }
    }

    public double Failed
    {
      get
      {
        return (double) Enumerable.Count<TestMethodRun>(Enumerable.Where<TestMethodRun>(this.TestMethods, (Func<TestMethodRun, bool>) (m => m.Status == "Failed")));
      }
    }

    public double Ignored
    {
      get
      {
        return (double) Enumerable.Count<TestMethodRun>(Enumerable.Where<TestMethodRun>(this.TestMethods, (Func<TestMethodRun, bool>) (m => m.Status == "Inconclusive")));
      }
    }

    public string Status
    {
      get
      {
        string str = "Failed";
        IEnumerable<IGrouping<string, TestMethodRun>> source = Enumerable.GroupBy<TestMethodRun, string>(this.TestMethods, (Func<TestMethodRun, string>) (m => m.Status));
        int num1 = Enumerable.Count<IGrouping<string, TestMethodRun>>(Enumerable.Where<IGrouping<string, TestMethodRun>>(source, (Func<IGrouping<string, TestMethodRun>, bool>) (k => k.Key == "Failed")));
        int num2 = Enumerable.Count<IGrouping<string, TestMethodRun>>(Enumerable.Where<IGrouping<string, TestMethodRun>>(source, (Func<IGrouping<string, TestMethodRun>, bool>) (k =>
        {
          if (!(k.Key == "Ignored") && !(k.Key == "NotRunnable"))
            return k.Key == "Aborted";
          else
            return true;
        })));
        if (num2 > 0)
          str = "Ignored";
        if (num1 == 0 && num2 == 0)
          str = "Succeed";
        return str;
      }
    }

    public TimeSpan Duration
    {
      get
      {
        return TimeSpan.FromTicks(Enumerable.Sum<TestMethodRun>(this.TestMethods, (Func<TestMethodRun, long>) (m => m.Duration.Ticks)));
      }
    }

    public string FullName
    {
      get
      {
        return this.fullname;
      }
    }

    public int Total
    {
      get
      {
        return Enumerable.Count<TestMethodRun>(this.TestMethods);
      }
    }

    public double PercentIgnored
    {
      get
      {
        return Math.Round(100.0 * (this.Ignored / (double) this.Total), 0);
      }
    }

    public double PercentKO
    {
      get
      {
        return Math.Round(100.0 * (this.Failed / (double) this.Total), 0);
      }
    }

    public double PercentOK
    {
      get
      {
        return Math.Round(100.0 * (this.Success / (double) this.Total), 0);
      }
    }

    public TestClassRun(string name, IEnumerable<TestMethodRun> methods)
    {
      this.fullname = name;
      this.TestMethods = (IEnumerable<TestMethodRun>) new List<TestMethodRun>(methods);
    }
  }
}
